/**
 * Created by Administrator on 2017/3/14.
 */
var Button = require('../../../src/libs/button');
var Input = require('../../../src/libs/input');
var Checkbox = require('../../../src/libs/checkbox');
var RealName = require('../complex/realName');
var Pagination = require('../../../src/libs/pagination');
var NoticeCenter = require('../complex/noticeCenter');
var Root = React.createClass({
    getInitialState: function () {
        return {
            delIds: [],
            realName:PageDM.realNameInfo.value,
            pageVal: PageDM.pagination.value,
            MessageListVal: PageDM.MessageList.value
        }
    },
    pageClick:function (v) {
        PageDM.pagination.setValue({curPage:v});
        PageDM.pagination.onClick(v);
    },
    componentDidMount: function(){
        var _this = this;
        UEventHub.emit("pageLoad","hello world!");

        UEventHub.on(PageDM.MessageList.dmbind + UI_EVENT_CONST.SET_UDM_VALUE_EVENT, function(v){
            _this.setState({
                MessageListVal: v
            });
        });
        //个人实名信息
        UEventHub.on(PageDM.realNameInfo.dmbind + UI_EVENT_CONST.SET_UDM_VALUE_EVENT, function(v){
            _this.refs.realName.setState({
                data: v
            })
        });
        UEventHub.on(PageDM.pagination.dmbind + UI_EVENT_CONST.SET_UDM_VALUE_EVENT, function(v){
            _this.setState({
                pageVal: v
            });
        });
        UEventHub.emit("pageLoad","hello world!");
    },
    render: function () {
        var _this = this;
        var notices_data = {
            notices: _this.state.MessageListVal,
            readAjax: PageDM.MessageList.readAjax,//点击信息展开后标记已读
            delAjax: PageDM.MessageList.delAjax   //删除请求
        }
        return (
            <div>
                <div className="mod-account container">
                    <div className="sub-nav">
                        <RealName ref="realName" data={_this.state.realName}/>
                    </div>
                    <div className="account padding">
                        <div className="message-center">
                            <div className="title-account"><span>消息中心</span></div>
                            <NoticeCenter data={notices_data} />
                            <Pagination  pageVal={_this.state.pageVal} onClick={this.pageClick}></Pagination>
                        </div>
                    </div>
                    <div className="clear"></div>
                </div>
            </div>
        )
    }
});
ReactDOM.render(<Root/>, document.getElementById('giraffe'));